from django.db import models
from hominin.specimens.models import Fossil

# Create your models here.

class Author(models.Model):
	first_name = models.CharField(max_length=30, blank=True, null=True)
	last_name = models.CharField(max_length=40)
	full_name = models.SlugField(max_length=61)

	def __unicode__(self):
		return u'%s %s' % (self.first_name, self.last_name)

class Book(models.Model):
	title = models.CharField(max_length=200, unique=True)
	subtitle = models.CharField(max_length=200, blank=True, null=True)
	authors = models.ManyToManyField(Author)
	publisher = models.CharField(max_length=40)
	edition = models.IntegerField(max_length=3)
	total_pages = models.IntegerField(max_length=5)
	isbn_10 = models.CharField(max_length=10)
	isbn_13 = models.CharField(max_length=15)
	referenced_fossils = models.ManyToManyField(Fossil)

	def __unicode__(self):
		return self.title
	
class Paper(models.Model):
	title = models.CharField(max_length=200, unique=True)
	authors = models.ManyToManyField(Author)
	abstract = models.TextField(max_length=2000)
	journal = models.CharField(max_length=200)
	publication_date = models.DateField()
	doi = models.CharField(max_length=100, unique=True)
	pmid = models.CharField(max_length=50, blank=True, null=True, unique=True)
	url = models.URLField()
	referenced_fossils = models.ManyToManyField(Fossil)

	def __unicode__(self):
		return self.title
